package top.pmwly.oauth2_jwt.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.oauth2.provider.token.AccessTokenConverter;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;
import org.springframework.security.oauth2.provider.token.store.JwtTokenStore;

/**
 * @author Herther
 * @version 1.0.0
 * @ClassName JwtTokenStoreConfig.java
 * @Description jwt 配置类
 * @createTime 2021年08月23日 14:51:00
 */
@Configuration
public class JwtTokenStoreConfig {




    @Bean
    public TokenStore jwtTokenStore(){
        return new JwtTokenStore(jwtAccessTokenConverter1());
    }

    /**
     * jwttoken 转换
     * @return
     */
    @Bean
    public JwtAccessTokenConverter jwtAccessTokenConverter1(){
        JwtAccessTokenConverter converter =new JwtAccessTokenConverter();
        //设置签名秘钥 也就是盐
        converter.setSigningKey("hello_word");
        return converter;
    }

    /**
     * 将刚才的类，注入带springioc中
     * @return
     */
    @Bean
    public JwtEnhancer jwtEnhancer(){
        return new JwtEnhancer();
    }

}
